package com.hlt.shuiliting.dao;

import java.util.List;
import java.util.Map;

import com.hlt.shuiliting.database.DBUtil;
import com.hlt.shuiliting.valuebean.ZhengDiCQ;

public class ZhengDiCQDAO {

	private int updateCount;
	
	public List list(int GongChengXMID) {
		String sql = "select * from ZhengDiCQ where GongChengXMID = ?";
		Object[] params = {GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet();
		myDB.closed();
		
		return list;
	}
	
	public Map view(int id) {
		List list = null;
		String sql = "select * from ZhengDiCQ where ID = ?";
		Object[] params = {id};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		list = myDB.getResultSet();
		Map map = (Map)list.get(0);
		
		return map;
	}
	public int insert(ZhengDiCQ ZhengDiCQ) {
		String sql = "insert ZhengDiCQ values (seq_ZhengDiCQ.nextVal, ?, to_date('?','yyyy-mm-dd'), ?,?, ?, ?, ?,?, ?, ?, to_date('?','yyyy-mm-dd'), ?, ?, ?, ?)";
		String ZhuangTai = ZhengDiCQ.getZhuangTai();
		String JiLuSJ = ZhengDiCQ.getJiLuSJ();
		String LuRuR = ZhengDiCQ.getLuRuR();
		String XiangMuYDSPBM = ZhengDiCQ.getXiangMuYDSPBM();
		String XiangMuYDSPYJ = ZhengDiCQ.getXiangMuYDSPYJ();
		String XiangMuYDXKZMH = ZhengDiCQ.getXiangMuYDXKZMH();
		String ChaiQianFZDW = ZhengDiCQ.getChaiQianFZDW();
		String ChaiQianFZR = ZhengDiCQ.getChaiQianFZR();
		String XiangMuZDCQGGBM = ZhengDiCQ.getXiangMuZDCQGGBM();
		String ChaiQianFW = ZhengDiCQ.getChaiQianFW();
		String ChaiQianSJ = ZhengDiCQ.getChaiQianSJ();
		String ChaiQianFS = ZhengDiCQ.getChaiQianFS();
		String ShangQiYZFJE = ZhengDiCQ.getShangQiYZFJE();
		String BenQiZFJE = ZhengDiCQ.getBenQiZFJE();
		String LeiJiZFJE = ZhengDiCQ.getLeiJiZFJE();
		Object[] params = {
				ZhuangTai, 
				JiLuSJ,
				LuRuR,
				XiangMuYDSPBM,
				XiangMuYDSPYJ,
				XiangMuYDXKZMH,
				ChaiQianFZDW,
				ChaiQianFZR,
				XiangMuZDCQGGBM,
				ChaiQianFW,
				ChaiQianSJ,
				ChaiQianFS,
				ShangQiYZFJE,
				BenQiZFJE,
				LeiJiZFJE};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int update(ZhengDiCQ ZhengDiCQ) {
		String sql = "update ZhengDiCQ set ZhuangTai = ?, JiLuSJ = to_date('?','yyyy-mm-dd'), LuRuR = ?, XiangMuYDSPBM = ?, XiangMuYDSPYJ = ?," +
				" XiangMuYDXKZMH = ?, ChaiQianFZDW = ?, ChaiQianFZR = ?, XiangMuZDCQGGBM = ?, " +
				"ChaiQianFW = ?, ChaiQianSJ = to_date('?','yyyy-mm-dd'), ChaiQianFS = ?, " +
				"ShangQiYZFJE = ?, BenQiZFJE = ?, LeiJiZFJE = ?, where ID = ?";
		String ID = ZhengDiCQ.getID();
		String ZhuangTai = ZhengDiCQ.getZhuangTai();
		String JiLuSJ = ZhengDiCQ.getJiLuSJ();
		String LuRuR = ZhengDiCQ.getLuRuR();
		String XiangMuYDSPBM = ZhengDiCQ.getXiangMuYDSPBM();
		String XiangMuYDSPYJ = ZhengDiCQ.getXiangMuYDSPYJ();
		String XiangMuYDXKZMH = ZhengDiCQ.getXiangMuYDXKZMH();
		String ChaiQianFZDW = ZhengDiCQ.getChaiQianFZDW();
		String ChaiQianFZR = ZhengDiCQ.getChaiQianFZR();
		String XiangMuZDCQGGBM = ZhengDiCQ.getXiangMuZDCQGGBM();
		String ChaiQianFW = ZhengDiCQ.getChaiQianFW();
		String ChaiQianSJ = ZhengDiCQ.getChaiQianSJ();
		String ChaiQianFS = ZhengDiCQ.getChaiQianFS();
		String ShangQiYZFJE = ZhengDiCQ.getShangQiYZFJE();
		String BenQiZFJE = ZhengDiCQ.getBenQiZFJE();
		String LeiJiZFJE = ZhengDiCQ.getLeiJiZFJE();
		Object[] params = {
				ZhuangTai, 
				JiLuSJ,
				LuRuR,
				XiangMuYDSPBM,
				XiangMuYDSPYJ,
				XiangMuYDXKZMH,
				ChaiQianFZDW,
				ChaiQianFZR,
				XiangMuZDCQGGBM,
				ChaiQianFW,
				ChaiQianSJ,
				ChaiQianFS,
				ShangQiYZFJE,
				BenQiZFJE,
				LeiJiZFJE,
				ID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int delete(int id) {
		String sql = "delete from ZhengDiCQ where ID = ?";
		Object[] params = {};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
}
